<template>
  <view class="page-container">
    <uni-nav-bar title="店铺信息管理" left-icon="back" @click-left="goBack" />

    <view class="content">
      <!-- 证照信息 -->
      <view class="menu-item" @click="goToLicenseInfo">
        <view class="menu-label">证照信息</view>
        <uni-icons type="right" color="#999" size="20"></uni-icons>
      </view>

      <!-- 证照信息更新 -->
      <view class="menu-item" @click="goToLicenseUpdate">
        <view class="menu-label">证照信息更新</view>
        <uni-icons type="right" color="#999" size="20"></uni-icons>
      </view>

      <!-- 平均客单价 -->
      <view class="menu-item" @click="goToAveragePrice">
        <view class="menu-label">平均客单价</view>
        <view class="menu-value">
          <text class="placeholder">请填写</text>
          <uni-icons type="right" color="#999" size="20"></uni-icons>
        </view>
      </view>

      <!-- 温馨提示 -->
      <view class="tips-container">
        <view class="tips-title">*温馨提示</view>
        <view class="tips-list">
          <view class="tips-item"
            >・营业执照如实更了法人请同步修改法人信息</view
          >
          <view class="tips-item"
            >・如营业执照需要到期3个月内请及时更新新的营业执照并提交修改</view
          >
          <view class="tips-item"
            >・如身份证距离到期3个月内请及时更新新的身份证并提交修改</view
          >
          <view class="tips-item"
            >・请确保提交的信息为最新的证件信息，保证信息准确</view
          >
        </view>
      </view>
    </view>

    <!-- 平均客单价弹窗 -->
    <uni-popup ref="averagePricePopup" type="center" :mask-click="false">
      <view class="price-modal">
        <view class="modal-header">
          <view class="modal-title">平均客单价</view>
          <view class="modal-close" @click="closeModal">
            <uni-icons type="closeempty" color="#999" size="20"></uni-icons>
          </view>
        </view>
        <view class="modal-content">
          <view class="input-label">请输入金额</view>
          <input
            type="digit"
            v-model="averagePrice"
            placeholder="请输入金额"
            class="price-input"
          />
        </view>
        <view class="modal-actions">
          <view class="modal-btn cancel" @click="closeModal">取消</view>
          <view class="modal-btn confirm" @click="confirmPrice">确定</view>
        </view>
      </view>
    </uni-popup>
  </view>
</template>

<script setup>
import { ref } from "vue";

// 弹窗引用
const averagePricePopup = ref(null);
// 平均客单价
const averagePrice = ref("");

// 返回上一页
const goBack = () => {
  uni.navigateBack();
};

// 跳转到证照信息页面（查看模式）
const goToLicenseInfo = () => {
  uni.navigateTo({
    url: "/pages/mine/storeInfo/licenseUpdate?mode=view",
  });
};

// 跳转到证照信息更新页面
const goToLicenseUpdate = () => {
  uni.navigateTo({
    url: "/pages/mine/storeInfo/licenseUpdate",
  });
};

// 打开平均客单价弹窗
const goToAveragePrice = () => {
  averagePricePopup.value.open();
};

// 关闭弹窗
const closeModal = () => {
  averagePricePopup.value.close();
  averagePrice.value = "";
};

// 确定平均客单价
const confirmPrice = () => {
  if (!averagePrice.value) {
    uni.showToast({
      title: "请输入金额",
      icon: "none",
    });
    return;
  }

  // TODO: 提交平均客单价到服务器
  uni.showToast({
    title: "设置成功",
    icon: "none",
  });

  closeModal();
};
</script>

<style lang="scss" scoped>
.page-container {
  min-height: 100vh;
  background-color: #f5f5f5;
}

.content {
  padding: 20rpx 32rpx;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fff;
  padding: 32rpx;
  margin-bottom: 2rpx;

  &:first-child {
    border-radius: 12rpx 12rpx 0 0;
  }

  &:nth-child(3) {
    border-radius: 0 0 12rpx 12rpx;
    margin-bottom: 0;
  }
}

.menu-label {
  font-size: 28rpx;
  color: #333;
}

.menu-value {
  display: flex;
  align-items: center;
  gap: 8rpx;

  .placeholder {
    font-size: 28rpx;
    color: #999;
  }
}

.tips-container {
  margin-top: 40rpx;
  padding: 0 32rpx;
}

.tips-title {
  font-size: 28rpx;
  color: #ff0000;
  font-weight: 500;
  margin-bottom: 16rpx;
}

.tips-list {
  .tips-item {
    font-size: 24rpx;
    color: #666;
    line-height: 40rpx;
    margin-bottom: 8rpx;
  }
}

// 平均客单价弹窗样式
.price-modal {
  width: 600rpx;
  background-color: #fff;
  border-radius: 16rpx;
  overflow: hidden;
}

.modal-header {
  position: relative;
  padding: 16rpx 32rpx;
  text-align: center;
  border-bottom: 1rpx solid #f0f0f0;
}

.modal-title {
  font-size: 32rpx;
  color: #333;
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 0;
  right: 32rpx;
  padding: 8rpx;
}

.modal-content {
  padding: 40rpx 32rpx;
}

.input-label {
  font-size: 28rpx;
  color: #666;
  margin-bottom: 16rpx;
}

.price-input {
  width: 100%;
  height: 80rpx;
  border: 1rpx solid #e5e5e5;
  border-radius: 8rpx;
  padding: 0 24rpx;
  font-size: 28rpx;
  color: #333;
  box-sizing: border-box;

  &::placeholder {
    color: #999;
  }
}

.modal-actions {
  display: flex;
  gap: 24rpx;
  padding: 0 32rpx 32rpx;
}

.modal-btn {
  flex: 1;
  height: 80rpx;
  line-height: 80rpx;
  text-align: center;
  border-radius: 40rpx;
  font-size: 28rpx;
  font-weight: 500;

  &.cancel {
    background-color: #f5f5f5;
    color: #666;
    border: 1rpx solid #e5e5e5;
  }

  &.confirm {
    background-color: #ffbb00;
    color: #fff;
  }
}
</style>
